﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>菜单</title>
    <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
    <link href="../Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="../Style/skin/font/iconfont.css" rel="stylesheet" type="text/css" />
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row c" id="lists">
        </div>
    </div>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../Style/skin/js/mp.mansory.min.js"></script>
    <script src="../Scripts/layui/layui/lay/modules/layer.js"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="../Comm/Gener.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">

        //查询
        function WinOpenSearch(flowNo, title) {
            var intFlowNo = flowNo;
            var url = "../RptDfine/Default.htm?RptNo=ND" + Number(flowNo) + "MyRpt&FK_Flow=" + flowNo;
            window.open(url);
            return;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: title + ' : 查询主页',
                area: ['96%', '90%'],
                content: url
            });
        }

        //我的流程
        function WinOpenMyFlow(flowNo, title) {
            var intFlowNo = flowNo;
            var url = "Search.htm?RptNo=ND" + Number(flowNo) + "MyRpt&FK_Flow=" + flowNo;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: title + ' : 我的流程',
                area: ['96%', '90%'],
                content: url
            });
        }

        //我发起的流程.
        function WinOpenFrmHome(frmID, title, entityType) {

            var url = "";
            if (entityType == 1)
                url = "SearchBill.htm?FrmID=" + frmID;

            if (entityType == 1 || entityType == 2)
                url = "SearchDict.htm?FrmID=" + frmID;

            WinOpenFull(url, frmID);
            return;
        }

        //我发起的流程.
        function WinOpenStart(frmID, title, entityType) {

            var handler = new HttpHandler("BP.CCBill.WF_CCBill");
            handler.AddPara("FrmID", frmID);

            var url = "";
            if (entityType == 1) {
                var workID = handler.DoMethodReturnString("MyBill_CreateBlankBillID");
                url = "MyBill.htm?FrmID=" + frmID + "&WorkID=" + workID;
            }

            if (entityType == 1 || entityType == 2) {
                var workID = handler.DoMethodReturnString("MyBill_CreateBlankBillID");
                url = "MyDict.htm?FrmID=" + frmID + "&WorkID=" + workID;
            }

            WinOpenFull(url, frmID);
            return;


            //window.open(url);
            // return;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: title + ' : 我发起的流程',
                area: ['96%', '90%'],
                content: url
            });
        }


        //页面启动函数.
        $(function () {

            InitPage();

            jQuery(document).ready(function ($) {
                $(".c").mpmansory({
                    childrenClass: 'itemt', // default is a div
                    columnClasses: 'paddings', //add classes to items
                    breakpoints: {
                        lg: 4,
                        md: 4,
                        sm: 4,
                        xs: 12
                    },
                    distributeBy: {
                        order: false,
                        height: false,
                        attr: 'data-order',
                        attrOrder: 'asc'
                    }, //default distribute by order, options => order: true/false, height: true/false, attr => 'data-order', attrOrder=> 'asc'/'desc'

                });
            });
        });

        //初始化数据.
        function InitPage() {

            $('#lists').html("正在加载发起流程列表,请稍后...");

            var handler = new HttpHandler("BP.CCBill.WF_CCBill");
            var data = handler.DoMethodReturnString("Start_Init");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            data = JSON.parse(data);

            //取出来两个结果集.
            var dtSort = data["Sort"]; //类别.
            var dtStart = data["Start"]; //发起的流程.

            var myNum = 0;
            var is1 = false;
            var listbox = '';
            for (var i = 0; i < dtSort.length; i++) {

                var sortNo = dtSort[i].No;
                var sortName = dtSort[i].Name;
                if (sortName == "" || sortName == null)
                    continue;

                //检查该类别下是否有流程，没有流程就 continue;
                var isHaveFlow = false;
                for (var myIdx = 0; myIdx < dtStart.length; myIdx++) {

                    var frm = dtStart[myIdx];
                    var flowSort = frm.FK_FormTree;
                    if (sortNo == flowSort) {
                        isHaveFlow = true;
                        break;
                    }
                }
                if (isHaveFlow == false)
                    continue;


                listbox += "<div class='itemt' data-order='" + myNum + "'><div class='ibox float-e-margins'><div class='ibox-title'><h5>" + sortName + "</h5><div class='ibox-tools'><a class='collapse-link' data-toggle='collapse'  href='#collapse" + myNum + "'><i class='fa fa-chevron-down' alert='Min' id='Img" + myNum + "' onclick=\"GroupBarClick('" + myNum + "')\"></i></a></div></div><div id='collapse" + myNum + "' class='ibox-contents collapse in'><table class='table table-striped notab'><tbody>";


                //增加处理.
                for (var idx = 0; idx < dtStart.length; idx++) {

                    var frm = dtStart[idx];
                    var flowSort = frm.FK_FormTree;
                    if (sortNo != flowSort)
                        continue;

                    listbox += "<tr>";
                    listbox += "  <td>";

                    if (frm.EntityType == 1)
                        listbox += "<a href=\"javascript:LanchBill('" + frm.No + "','" + sortName + " - " + frm.Name + "');\" > &sdot; " + frm.Name + "</a></td><td class='chooser'><a class='dropdown-toggle' data-toggle='dropdown' href='#'><i class='icon iconfont icon-gongju1'></i></a>";
                    if (frm.EntityType == 2)
                        listbox += "<a href=\"javascript:LanchDict('" + frm.No + "','" + sortName + " - " + frm.Name + "');\" > &sdot; " + frm.Name + "</a></td><td class='chooser'><a class='dropdown-toggle' data-toggle='dropdown' href='#'><i class='icon iconfont icon-gongju1'></i></a>";



                    listbox += "<ul class='dropdown-menu dropdown-user'>";

                    listbox += "<li><a href=\"javascript:WinOpenStart('" + frm.No + "','" + sortName + " - " + frm.Name + "','" + frm.EntityType + "');\" >新建</a></li>";

                    listbox += "<li><a href=\"javascript:WinOpenFrmHome('" + frm.No + "','" + sortName + " - " + frm.Name + "','" + frm.EntityType + "');\" >查询</a></li>";

                    //	listbox+="<li><a href=\"javascript:WinOpenMyFlow('" + frm.No + "','" +sortName+ " - "+ frm.Name + "');\" ><font color=red>*</font>我的流程</a></a></li>";
                    //	listbox+="<li><a href=\"javascript:WinOpenSearch('" + frm.No + "','" +sortName+ " - "+ frm.Name + "');\" >查询主页</a></li></ul>";
                    listbox += "</ul>";

                    listbox += "  </td>";
                    listbox += "</tr>";

                }
                listbox += '</tbody></table></div></div></div>';
                myNum++;
            }

            // listbox+="<a href='GenerBill.htm'>单据列表</a>";
            $('#lists').html(listbox);
        }

        //发起时打开窗口
        function LanchBill(frmID, title) {

            var url = "SearchBill.htm?FrmID=" + frmID + "&FK_MapData=" + frmID;
            window.location.href = url;
            return;
            layer.open({
                skin: 'layer-class',
                type: 2,
                title: title + ' : 发起申请',
                area: ['96%', '90%'],
                content: url
            });
        }
        //发起时打开窗口
        function LanchDict(frmID, title) {

            var url = "SearchDict.htm?FrmID=" + frmID + "&FK_MapData=" + frmID;
            window.location.href = url;
        }
        function Ref() {
            window.location.href = 'Start.htm?IsRef=1';
        }
        function GroupBarClick(groupName) {

            var alt = document.getElementById('Img' + groupName).alert;
            var sta = 'block';
            if (alt == 'Max') {
                sta = 'block';
                alt = 'Min';
                classname = 'fa fa-chevron-down';
            } else {
                sta = 'none';
                alt = 'Max';
                classname = 'fa  fa-chevron-up';
            }

            document.getElementById('Img' + groupName).className = classname;
            document.getElementById('Img' + groupName).alert = alt;

            var i = 0;
            for (i = 0; i <= 600; i++) {

                var row = document.getElementById(groupName + i);

                if (row == null || row == undefined || row.style == null)
                    continue;

                if (sta == 'block') {
                    row.style.display = '';
                } else {
                    row.style.display = sta;
                }
            }
        }
    </script>
</body>
</html>
